package com.xz.springbootvuebackend.exception;


import com.xz.springbootvuebackend.common.ErrorCode;
import lombok.Getter;

import java.io.Serializable;

/**
 * @author xuzhou
 * @version 1.0
 * <p>
 * 自定义异常类
 */
@Getter
public class BusinessException extends RuntimeException implements Serializable {
    private static final long serialVersionUID = 9138232496851772014L;
    private final int code;
    private final String description;

    public BusinessException(String message, int code, String description) {
        super(message);
        this.code = code;
        this.description = description;
    }

    public BusinessException(ErrorCode errorCode, String description) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = description;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = errorCode.getDescription();
    }

}
